package com.triones.api.controller.web;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysNotice;
import com.triones.api.entity.RichContentDO;
import com.triones.api.service.RichContentService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 富文本
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/richContent")
public class RichContentController extends BaseController {

    private final RichContentService richContentService;

    /**
     * 详细信息
     */
    @SaCheckPermission("system:richContent:handle")
    @GetMapping(value = "/{type}")
    public R<RichContentDO> getInfo(@PathVariable String type) {
        return R.ok(richContentService.selectById(type));
    }

    /**
     * 新增
     */
    @SaCheckPermission("system:richContent:handle")
    @PostMapping
    public R<Void> add(@Validated @RequestBody RichContentDO dto) {
        return toAjax(richContentService.insert(dto));
    }

    /**
     * 修改
     */
    @SaCheckPermission("system:richContent:handle")
    @PutMapping
    public R<Void> edit(@Validated @RequestBody RichContentDO dto) {
        return toAjax(richContentService.update(dto));
    }
}
